import { util } from '../../../../utils/util'
var app = getApp();
//考试成绩
Page({
  mixins: [],
  data: {
     activityType:'',    //活动类型
     instanceType:'',       //实例类型
     currdate : util.formatDateTime(new Date()),

    //  分数型
    chinese_sfx: '',
    math_sfx: '',
    english_sfx: '',
    polity_sfx: '',
    history_sfx: '',
    geography_sfx: '',
    physics_sfx: '',
    chemistry_sfx: '',
    biology_sfx: '',
    infoTech_sfx: '',
    generalTech_sfx: '',
    music_sfx: '',
    arts_sfx: '',
    sports_sfx: '',


    //  合格型
    chinese: '',
    math: '',
    english: '',
    polity: '',
    history: '',
    geography: '',
    physics: '',
    chemistry: '',
    biology: '',
    infoTech: '',
    generalTech: '',
    music: '',
    arts: '',
    sports: '',


     
    oneIndex: 0,
    towIndex: 0,
    hide:0,
     oneArray: [
      {id: 0,type:1, name: '分数型',},{id: 1,type:2, name: '等级型(高考)',},{id: 2,type:3, name: '合格型(会考)',}
     ],
     towArray: [
      {id: 0,type:1, name: '第一学期',},{id: 1,type:2, name: '第二学期',},{id: 2,type:3, name: '第三学期',}
     ],


    fractionArrYW:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSX:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrWY:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSXZZ:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrLS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrDL:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrWL:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrHX:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSW:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrXXJS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrTYJS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrYY:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrMS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrTYYJK:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],


    qualifiedArrYW:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSX:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrWY:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSXZZ:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrLS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrDL:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrWL:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrHX:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSW:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrXXJS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrTYJS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrYY:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrMS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],qualifiedArrTYYJK:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    },

    // 分数型选择
    on_fractionArrYW(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrYW;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.chinese_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrSX(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrSX;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.math_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrWY(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrWY;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.english_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrSXZZ(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrSXZZ;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.polity_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrLS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrLS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.history_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrDL(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrDL;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.geography_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrWL(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrWL;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.physics_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrHX(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrHX;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.chemistry_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrSW(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrSW;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.biology_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrXXJS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrXXJS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.infoTech_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrTYJS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrTYJS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.generalTech_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrYY(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrYY;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.music_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrMS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrMS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.arts_fsx=arr[index].id;
      me.setData( me.data);
    },
    on_fractionArrTYYJK(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.fractionArrTYYJK;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.sports_fsx=arr[index].id;
      me.setData( me.data);
    },



    // 合格性选择
    on_qualifiedArrYW(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrYW;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.chinese=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrSX(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrSX;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.math=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrWY(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrWY;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.english=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrSXZZ(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrSXZZ;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.polity=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrLS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrLS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.history=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrDL(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrDL;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.geography=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrWL(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrWL;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.physics=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrHX(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrHX;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.chemistry=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrSW(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrSW;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.biology=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrXXJS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrXXJS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.infoTech=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrTYJS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrTYJS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.generalTech=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrYY(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrYY;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.music=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrMS(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrMS;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.arts=arr[index].id;
      me.setData( me.data);
    },
    on_qualifiedArrTYYJK(e){
      var me = this;
      console.log(e.currentTarget.dataset.index)
      let index=e.currentTarget.dataset.index;
      let arr=me.data.qualifiedArrTYYJK;
      let i=0;
      for(;i<arr.length;i++){arr[i].css=''}
      arr[index].css = ' active';
      me.data.sports=arr[index].id;
      me.setData( me.data);
    },

    onSubmit(e) {
      var me = this;
      var obj = e.detail.value;
      var dataObj=obj;
      //做非空校验
      if(util.validation(dataObj)){
          obj['files'] = me.data.honorFiles;
          obj['activityType'] = parseInt(me.data.activityType);
          obj['instanceType'] = parseInt(me.data.instanceType);
          console.info(obj);
           var postdata = {
               activityType: parseInt(me.data.activityType),
               instanceType: parseInt(me.data.instanceType),
               itemInfo : obj,
               };
           //调用提交方法
           util.submitRecord(postdata);
      } 
    },  
 oneBindObjPickerChange(e) {
    console.log('1picker发送选择改变，携带值为', e.detail.value);
    var a = e.detail.value;
    this.setData({
      oneIndex: e.detail.value,
      
    });

    if(a==0){
      this.data.hide = 0
    }else if(a==1){
      this.data.hide = 1
    }else{
      this.data.hide = 2
    }
    this.setData(this.data)
  },
  towBindObjPickerChange(e) {
    console.log('1picker发送选择改变，携带值为', e.detail.value);
    this.setData({
      towIndex: e.detail.value,
    });
  },
  
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
     var arr = query.honorFiles.split(",");
    this.setData({
      activityType: query.activityType,
      instanceType: query.instanceType,
      honorFiles: arr,
       //  分数型
    chinese_sfx: '',
    math_sfx: '',
    english_sfx: '',
    polity_sfx: '',
    history_sfx: '',
    geography_sfx: '',
    physics_sfx: '',
    chemistry_sfx: '',
    biology_sfx: '',
    infoTech_sfx: '',
    generalTech_sfx: '',
    music_sfx: '',
    arts_sfx: '',
    sports_sfx: '',


    //  合格型
    chinese: '',
    math: '',
    english: '',
    polity: '',
    history: '',
    geography: '',
    physics: '',
    chemistry: '',
    biology: '',
    infoTech: '',
    generalTech: '',
    music: '',
    arts: '',
    sports: '',


     
    oneIndex: 0,
    towIndex: 0,
    hide:0,
     oneArray: [
      {id: 0,type:1, name: '分数型',},{id: 1,type:2, name: '等级型(高考)',},{id: 2,type:3, name: '合格型(会考)',}
     ],
     towArray: [
      {id: 0,type:1, name: '第一学期',},{id: 1,type:2, name: '第二学期',},{id: 2,type:3, name: '第三学期',}
     ],


    fractionArrYW:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSX:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrWY:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSXZZ:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrLS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrDL:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrWL:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrHX:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrSW:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrXXJS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrTYJS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrYY:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrMS:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],
    fractionArrTYYJK:[
        {css:' ',id:'1',value:'必修'},{css:'',id:'2',value:'选修'}
    ],


    qualifiedArrYW:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSX:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrWY:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSXZZ:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrLS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrDL:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrWL:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrHX:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrSW:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrXXJS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrTYJS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrYY:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    qualifiedArrMS:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],qualifiedArrTYYJK:[
        {css:' ',id:'1',value:'合格'},{css:'',id:'2',value:'不合格'}
    ],
    });
  },
  onUnload() {
    // 页面被关闭
    wx.setStorageSync("honorFiles", []);
  },
});
